package edu.ubb.bibliospring.rsclient;

import edu.ubb.bibliospring.common.dto.AuthorDto;
import java.util.Arrays;
import org.apache.log4j.BasicConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main {

    public static void main(String... args) {
        BasicConfigurator.configure();
        final Logger logger = LoggerFactory.getLogger(Main.class);

        AuthorManager authorManager = new AuthorManager();

        System.out.println("Inserting Author");
        logger.info("Inserting Author");
        AuthorDto author = new AuthorDto();
        author.setFirstName("Zsolt");
        author.setLastName("Sebestyen");

        author = authorManager.insertAuthor(author);
        System.out.println("Author inserted");
        logger.info("Author inserted");

        System.out.println("Getting ALL Authors");
        logger.info("Getting ALL Authors");
        System.out.println(Arrays.toString(authorManager.getAllAuthors().toArray()));
        logger.info(Arrays.toString(authorManager.getAllAuthors().toArray()));

        System.out.println("Get author by Id");
        logger.info("Get author by Id");
        author = authorManager.getAuthorById(Integer.parseInt("" + author.getId()));
        System.out.println("Requested author is: " + author.toString());
        logger.info("Requested author is: " + author.toString());

        System.out.println("Deleting Author");
        logger.info("Deleting Author");
        authorManager.deleteAuthor(author);
        System.out.println("Author Deleted");
        logger.info("Author Deleted");

        System.out.println("Getting ALL Authors");
        logger.info("Getting ALL Authors");
        System.out.println(Arrays.toString(authorManager.getAllAuthors().toArray()));
        logger.info(Arrays.toString(authorManager.getAllAuthors().toArray()));
    }
}
